#!/bin/bash

. common.sh 

echo FFMPEG

VERSION=latest-git

cd $SRC
rm -rf ffmpeg
git clone git://git.videolan.org/ffmpeg.git ffmpeg
#curl -O -C - http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
#tar xvjf ffmpeg-snapshot.tar.bz2
cd ffmpeg || exit 2


OPTARCH=" --arch=x86_64"
if [ -f "/usr/bin/gcc-4.2" ] 
then
COMPILATEUR="--cc=/usr/bin/gcc-4.2"
else
COMPILATEUR="--cc=/usr/bin/llvm-gcc-4.2"
fi

./configure --prefix=${PREFIX} $COMPILATEUR  --extra-version="KaKoLa" --enable-swscale --enable-avfilter     \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libopencore-amrnb --enable-libmp3lame --enable-libx264 --enable-libxvid \
--enable-version3 --enable-zlib --disable-ffplay --disable-ffserver --enable-doc \
--enable-libfaac --enable-gpl --enable-nonfree --enable-pthreads --disable-yasm \
--extra-cflags="-I${PREFIX}/include/ -I${PREFIX}/include/vpx/ -I${PREFIX}/include/a52dec/ -I${PREFIX}/include/lame/ -I${PREFIX}/include/ -I${PREFIX}/include/ao -I${PREFIX}/include/ogg  -I${PREFIX}/include/vorbis  -I${PREFIX}/include/theora " \
--extra-ldflags=-L${PREFIX}/lib $OPTARCH  || exit 2

make libavcodec/libvpxenc.o
make   || exit 2
make install  || exit 2
mkdir -p "${PREFIX}/share/doc/ffmpeg/"
cp -r -p doc/*.html "${PREFIX}/share/doc/ffmpeg/"




#YASMTARGET=/usr/local/yasm-${ARCH}
#echo YASM
#cd $SRC
#curl -O -C - http://www.tortall.net/projects/yasm/releases/yasm-1.0.0.tar.gz
#tar xvzf yasm-1.0.0.tar.gz 
#cd yasm-1.0.0
#./configure --prefix=$YASMTARGET --enable-shared=no --enable-static=yes || shellout "./configure --prefix=$YASMTARGET --enable-shared=no --enable-static=yes"
#make || shellout "make yasm-1.0.0"
#make install || shellout "make install yasm-1.0.0"
#PATH=${YASMTARGET}/bin:$PATH

#NASMTARGET=/usr/local/nasm-${ARCH}
#echo NASM
#cd $SRC
##curl -O -C - http://www.nasm.us/pub/nasm/releasebuilds/2.08.01/nasm-2.08.01.tar.bz2
#tar xvjf nasm-2.08.01.tar.bz2
#cd nasm-2.08.01
#./configure --prefix=$NASMTARGET --enable-shared=no --enable-static=yes  || shellout "./configure --prefix=$NASMTARGET --enable-shared=no --enable-static=yes"
#make || shellout "make nasm-2.08.01"
#make install || shellout "make install  nasm-2.08.01"
#PATH=${NASMTARGET}/bin:$PATH



#echo SPEEX
#C'esr cette version qu'il faut et non la 1.0.5 car elle ne se compilera pas
#cd $SRC
#curl -O -C - http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
#tar xvzf speex-1.2rc1.tar.gz 
#cd speex-1.2rc1
# ./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes --with-ogg=${PREFIX} --with-vorbis=${PREFIX}
#make && make install

#DIRAC et SCHROEDINGER
#cd $SRC
#curl -O -C - http://sourceforge.net/projects/dirac/files/dirac-codec/Dirac-1.0.2/dirac-1.0.2.tar.gz/download
#tar xvzf dirac-1.0.2.tar.gz 
#cd dirac-1.0.2
#./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes && make && make install

#cd $SRC
#curl -O -C - http://code.entropywave.com/download/orc/orc-0.4.4.tar.gz
#tar xvzf orc-0.4.4.tar.gz 
#cd orc-0.4.4
#./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes && make && make install

#cd $SRC
#curl -O -C - http://diracvideo.org/download/schroedinger/schroedinger-1.0.9.tar.gz
#tar xvzf schroedinger-1.0.9.tar.gz
#cd schroedinger-1.0.9
#./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes && make && make install

#FFPLAY (optionnel)
#Cette section est bien sûr optionnelle à moins que l'on veuille bénéficier du lecteur ffplay
#cd $SRC
#curl -O -C - http://www.libsdl.org/release/SDL-1.2.14.tar.gz
#tar xvzf SDL-1.2.14.tar.gz
#cd SDL-1.2.14
#./configure --prefix=${PREFIX} --enable-static=yes --enable-shared=no && make && make install

